<template>
  <div style="text-align: left">
    <el-dialog
      title="添加 / 修改可预约时间"
      :visible.sync="dialogFormVisible"
      @close="clearData"
      width="35%"
      center>
      <el-form :model="confirmForm" class="confirm-container" label-position="left" label-width="80px">
        <el-form-item label="选择日期">
          <el-date-picker
            v-model="value1"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button style="" v-on:click="confirm">提交
        </el-button>
        <el-button @click="dialogFormVisible = false" style="">取 消
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'EditAvailTime',
  data () {
    return {
      dialogFormVisible: false,
      confirmForm: {
        id: '',
        acc: '',
        ksrq: '',
        jsrq: ''
      },
      value1: []
    }
  },
  methods: {
    confirm () {
      this.confirmForm.ksrq = this.value1[0]
      this.confirmForm.jsrq = this.value1[1]
      this.$axios.post('teacher/user/edit_avail_time', {
        id: this.confirmForm.id,
        acc: this.confirmForm.acc,
        ksrq: this.confirmForm.ksrq,
        jsrq: this.confirmForm.jsrq
      }).then(resp => {
        this.userTime = resp.data
      }).catch(failResponse => {
        alert('服务器响应请求失败！')
      })
    },
    clearData () {
      Object.assign(this.$data, this.$options.data.call(this))
    }
  }
}
</script>

<style scoped>
.confirm-container {
  background-clip: padding-box;
  margin: 5px 5px;
  width: 350px;
  padding: 15px 15px 15px 15px;
  background: #fff;
}

.confirm_title {
  margin: 0px auto 18px;
  text-align: center;
  color: #9495c5;
}
</style>
